package Practice02;

import java.util.Scanner;

public class CalAirPrice {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入票价");
        double price = scanner.nextDouble();
        System.out.println("请输入月份");
        int month = scanner.nextInt();
        System.out.println("请输入舱位:1.头等舱  2.商务  3.经济");
        int type = scanner.nextInt();
        double finalprice = finalPrice(price, month, type);
        if (finalprice!=-1) {
            System.out.println("最终价格是" + finalprice);
        }

    }

    public static double finalPrice(double price, int month, int type) {
        double finalPrice = 0.0;
        if (month < 1 || month > 13) {
            System.out.println("输入月份错误");
            return -1;
        }
        if (type < 1 || type > 3) {
            System.out.println("输入舱位错误");
            return -1;
        }
        if (month >= 1 && month <= 6) {
            switch (type) {
                case 1:
                    finalPrice = price * 0.3;
                    break;
                case 2:
                    finalPrice = price * 0.4;
                    break;
                case 3:
                    finalPrice = price * 0.5;
                    break;
            }
        } else {
            switch (type) {
                case 1:
                    finalPrice = price * 0.8;
                    break;
                case 2:
                    finalPrice = price * 0.7;
                    break;
                case 3:
                    finalPrice = price * 0.6;
                    break;
            }
        }
        return finalPrice;
    }
}